import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.FileNotFoundException;

import javax.swing.JFrame;

public class circle extends Graph implements KeyListener {
int zeroCorrection=scale/2;
float angle=90.0f;
double oldx=5;
double oldy=0;

	public circle() {
		//super();
	}

	public static void main(String[] args) {

		JFrame f = new JFrame();
		circle g = new circle();
		// f.add(g);
		f.addKeyListener(g);
		f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		f.setBounds(200, 500, s_HEIGHT, s_HEIGHT + size);
		f.getContentPane().add(g);
		f.setVisible(true);

	}
	
	int getGraphX(int x){
		return x*size+zeroCorrection;
	}
	
	int getGraphY(int y){
		return -y*size+zeroCorrection;
	}
	@Override
		public void paint(Graphics g) {
//		g.setColor(Color.white);
//		g.fillRect(0, 0, s_WIDTH, s_HEIGHT);
		g.setColor(Color.black);
			super.paint(g);
			g.fillRect(getGraphX((int)oldx)-5,getGraphY((int)oldy)-5,10,10);
//			double x=oldx*Math.cos(angle) + oldy*Math.sin(angle);
//			double y=oldx*Math.cos(angle) - oldy*Math.sin(angle);
			double x=oldx*Math.cos(angle) - oldy*Math.sin(angle);
			double y=oldy*Math.cos(angle) + oldx*Math.sin(angle);
			oldx=x;
			oldy=y;
			angle+=0.1f;
			System.out.println((getGraphX((int)oldx)-5)+" "+(getGraphY((int)oldy)-5));
		}

	@Override
	public void keyPressed(KeyEvent e) {
		switch(e.getKeyCode()){
		case KeyEvent.VK_ESCAPE:
			System.exit(0);
			break;
		case KeyEvent.VK_SPACE:
			oldx++;
			oldy=0;
			break;
			
		case KeyEvent.VK_LEFT:
			oldx--;
			oldy=0;
			break;
		case KeyEvent.VK_RIGHT:
			oldx++;
			oldy=0;
			break;
		}
		
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}
}
